// pv 页面访问量 page view 用户每次对网站的访问均被记录
/**
 * history api -> go back forward pushState replaceState
 * history 无法通过popstate 监听 pushState replaceState 只能重写其函数在utils.pv
 * hash 使用hashchange 监听
 */

export const createHistoryEvent = <T extends keyof History>(type: T) => {

  const origin = history[type]
  return function(this: any) {
    const res = origin.apply(this, arguments)

    const evt = new Event(type)
    window.dispatchEvent(evt)

    return res
  }
}